Before you can rush off and begin compiling the source code on the CD-ROM, you need to ensure you have your development environment correctly prepared. The source code in this book was compiled using Microsoft Visual Studio(r) 6, so we will quickly run through the steps you need to take to prepare Visual Studio 6. If you are using a newer version of Visual Studio (or a different compiler all together), most (if not all) of these steps will still apply; how you go about them will be a little different. In this case, you may need to refer to your compiler's documentation to determine how to carry out a particular step.
Step 1: Ensure that Visual Studio is properly installed on your computer. You should also ensure that your compiler has the latest patches and service packs applied to correct any known issues and bugs.
Step 2: Install the DirectX 9.0c SDK, which you can find on the CD-ROM in the DirectX directory.
Step 3: The next step is to ensure you have the DirectX Include and Library directories set within your compiler. In Visual Studio 6, open the Options dialog from the Tools menu. From there, select the Directories tab. In the "Show directories for" drop-down list, select Include files. Ensure that your DirectX Include directory is at the top of the Directories list. If not, simply use the Up arrow on the right to push it to the top of the list. This will ensure that it is searched before the other directories. If it is not in the list at all, you will need to add it by using the New button and browsing your hard drive. Once this is done you can go to the Library files in the "Show directories for" drop-down list. You just need to repeat the process for the DirectX Library (Lib) directory, ensuring that it is located at the top of the Directories list.
Step 4: As of the DirectX 9.0c release, Visual Studio 6 is no longer supported. However, Microsoft did release a modified version of one of the core DirectX libraries, which makes it possible to compile DirectX 9.0c applications with Visual Studio 6. If you are using a later version of Visual Studio then you can ignore this step. For everyone else, you will need to copy the Visual Studio 6 compatible d3dx9.lib file from the DirectX directory on the CD-ROM to the Lib directory on your hard drive where you installed the DirectX 9.0c SDK (C:\Program Files\Microsoft DirectX 9.0 SDK (October 2004)\Lib by default). Simply replace the existing d3dx9.lib file when prompted. If you plan on upgrading to a future version of Visual Studio, you may want to consider making a backup of the existing d3dx9.lib file before you replace it, as it is needed for future versions.
Step 5: There is one more file required to compile DirectX 9.0c applications with Visual Studio 6, called BaseTsd.h. If you have a later version of Visual Studio you may be able to skip this step. The file can only be obtained by updating your Platform SDK from the Microsoft Platform SDK Update Web site at www.microsoft.com/msdownload/platformsdk/sdkupdate/.
From here you can navigate to Downloads and
select Install, which will allow you to install the updated Platform SDK. Once you have the Platform SDK installed, you need to ensure the paths are set up correctly in Visual Studio. This is done in exactly the same fashion as setting the DirectX SDK paths. You need to ensure that you have both the Include and the Library paths set, which are located at <Platform SDK Installation Path>\Include\ and <Platform SDK Installation Path>\Lib\ respectively.
Note: If you cannot download the Platform SDK for some reason, there is a quick "hack" that you can apply to the code in this book that will allow it to compile and run without the updated Platform SDK. However, it is strongly recommended that you use the Platform SDK instead. To apply this hack, simply place the following line of code at the beginning of one of the main header files, such as Engine.h.
typedef unsigned long DWORD_PTR;
That's it. Now you are ready to compile DirectX 9.0c applications (and the book's source code) in Visual Studio 6. Remember, if you are using a different compiler (or a different version of Visual Studio), you may need to double check if all of these step are necessary for you. You may also need to refer to your compiler's documentation about the specific steps involved for adding the DirectX (and Platform SDK) Include and Library directories. If you are using a newer version of Visual Studio, you can open up the workspaces on the CD-ROM and allow the conversion wizard to upgrade them for you. Once it is finished, you should be able to compile the code without any major issues.
A Final Note
You should keep an eye on my Web site (www.coderedgames.com) or visit
www.charlesriver.com for updates to the book and the code as necessary. I will also have a forum set up on my Web site to allow you to raise any issues you may have with any of the material in the book, or the source code.
If you find any problems, have any comments or suggestions, or just want to say hi, please e-mail me at vyoung@coderedgames.com. By all means, if you find a fix for a bug, add a new feature to the engine, or make any sort of improvement that you would like to share, send it along and I will make it available for everyone.